﻿using System;
using System.Runtime.InteropServices;

namespace DataMgr.mode
{
	/// <summary>
	/// 单工步信息
	/// </summary>
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public class SingleStepInfo
	{
		/// <summary>
		/// 工步号
		/// </summary>
		public int StepNo;
		/// <summary>
		/// 工步单元数据长度
		/// </summary>
		public int StepUnitDataLength;
		/// <summary>
		/// 工步名称
		/// </summary>
		public byte StepName;
		/// <summary>
		/// 参数数据个数
		/// </summary>
		public int ParamDataCount;
		/// <summary>
		/// 工步参数
		/// </summary>
		public double[] StepParams;

		/// <summary>
		/// 截止条件数量
		/// </summary>
		public byte CutOffConditionCount;
		/// <summary>
		/// 截止条件
		/// </summary>
		public CutOffCondition[] CutOffConditions;

		/// <summary>
		/// 记录条件个数
		/// </summary>
		public byte RecordConditionCount;
		/// <summary>
		/// 记录条件
		/// </summary>
		public RecordCondition[] RecordConditions;

		/// <summary>
		/// 扩展参数个数
		/// </summary>
		public int ExpandParamCount;
		/// <summary>
		/// 扩展参数
		/// </summary>
		public ExpandParam[] ExpandParams;

		/// <summary>
		/// StepParam构造
		/// </summary>
		/// <param name="cutOffConditionCount">截止条件数量</param>
		/// <param name="recordConditionCount">记录条件数量</param>
		/// <param name="expandParamCount">扩展参数数量</param>
		public SingleStepInfo(byte cutOffConditionCount,byte recordConditionCount, int expandParamCount)
		{
			this.CutOffConditionCount = cutOffConditionCount;
			this.RecordConditionCount = recordConditionCount;
			this.ExpandParamCount = expandParamCount;
			this.CutOffConditions = new CutOffCondition[CutOffConditionCount];
			this.RecordConditions = new RecordCondition[RecordConditionCount];
			this.ExpandParams = new ExpandParam[ExpandParamCount];
		}

		public SingleStepInfo()
		{
			
		}
	}

	/// <summary>
	/// 截止条件
	/// </summary>
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public struct CutOffCondition
	{
		/// <summary>
		/// 截止条件的类型
		/// </summary>
		public int CutOffConditionType;
		/// <summary>
		/// 截止条件的类型参数值关系
		/// </summary>
		public byte CutOffConditionParamCondition;
		/// <summary>
		/// 截止条件参数
		/// </summary>
		public double CutOffConditionParam;
		/// <summary>
		/// 截止条件的与或关系
		/// </summary>
		public byte CutOffConditionRaletion;
		/// <summary>
		/// 截止条件的处理类型
		/// </summary>
		public byte CutOffConditionProcessingType;

	}

	/// <summary>
	/// 记录条件
	/// </summary>
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public struct RecordCondition
	{
		/// <summary>
		/// 记录条件类型
		/// </summary>
		public byte RecordConditionType;
		/// <summary>
		/// 记录条件参数
		/// </summary>
		public double RecordConditionParam;
	}

	/// <summary>
	/// 扩展参数
	/// </summary>
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public class ExpandParam
	{
		/// <summary>
		/// 扩展参数类型
		/// </summary>
		public int ExpandParamType;
		/// <summary>
		/// 扩展参数的参数个数
		/// </summary>
		public int ExpandParamParamCount;
		/// <summary>
		/// 扩展参数的参数值
		/// </summary>
		public double[] ExpandParamParamValues;

	}

}